

<template>
  <div class="mainBox">
    <div class="mainTitle">试题配置</div>
    <div class="btnBox"><el-button class="mainBtn"  @click="openDrawerCom">新增</el-button></div>

    <el-table :data="tableData" style="width: 100%"  height=" calc(100vh - 310px)"
> 
      <el-table-column type="index" width="60" label="序号" />
      <el-table-column prop="title" label="题目" width="" />
      <el-table-column prop="createTime" label="创建时间" width="" />
      <el-table-column fixed="right" label="操作" width="120">
         <template #default="scope">
       
          <el-button class="deleteBtnL" link @click="delteList(scope.row.id)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
<Pagination  @tips="tips" ref="pagination"/>
    <DrawerItem ref="drawerItem" @getLists="getLists" />

  </div>
</template>
<script  setup>
import { topicList,topicDelete } from "../../api/index";
import { ref, onMounted } from "vue";
import { ElMessage, ElMessageBox } from "element-plus"; 
import Pagination from "../../components/Pagination/index.vue"

const tableData = ref([]);

const pagination = ref(null)

const getList = (val) => {

     console.log(pagination.value.paginationData.currentPage);
  let parmas = {
    pageNo: val,
    pageSize: 10,
  };
  topicList(parmas).then((res) => {
    if (res.code == 200) {
  pagination.value.paginationData.currentPage =Number(val)
  pagination.value.paginationData.total =Number(res.data.total)
      tableData.value = res.data.records;
    }
  });
};
onMounted(() => {
  getList(1);
});

const tips = (data) => {
  console.log(data);
  getList(data);
};


const delteList = (id) => {
  console.log(id);
  let parmas = {
    id: id,
  };
  topicDelete(parmas).then((res) => {
    if (res.code === '200') {
      ElMessage.success("删除成功");
      getList(1);
    } else {
      ElMessage.error("删除失败");
    }
  });
};

import DrawerItem from "./components/drawerItem.vue";
const drawerItem = ref(null);
const openDrawerCom = () => {
  drawerItem.value.drawerData.open = true;
  drawerItem.value.drawerData.title = "新增专题";
  drawerItem.value.form.title = '';
  drawerItem.value.form.file = '';
};


const getLists = (data) => {
  getList(1);
};

</script>
<style lang="scss" scoped>
.mainBox {
  background: #ffffff;
  border-radius: 8px;
  padding: 16px;
  margin: 24px;
  min-height: calc(100vh - 56px - 48px - 40px);
  min-width: 1200px;
  overflow: auto;
  .mainTitle {
    font-size: 16px;
    font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
    font-weight: bold;
    color: #333333;
    margin-bottom: 16px;
    padding-top: 16px;
  }
  .btnBox{
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
  }
}
:deep(.el-table) {
    --el-table-border-color: rgba(255, 255, 255, 0);
    .el-table__header .el-table__cell {
      background: #f7f8fa;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      color: #333333;
      border-color: #ebebeb;
    }
    .el-table__header .is-group tr:first-child .el-table__cell {
      background: #f7f8fa;
    }
    .el-table__body .el-table__cell {
      padding: 0px;
      height: 32px;
      border-left: none;
      border-right: none;
      border-color: #ebebeb;
      font-size: 14px;
      font-family: MicrosoftYaHei;
      color: #666666;
    }

    .tableBtn {
      color: #155bd3;
      font-size: 14px;
      font-family: MicrosoftYaHei;
    }
  }
</style>

